package nciae.db.service.impl;

import nciae.db.mapper.SettingsMapper;
import nciae.db.pojo.entity.Settings;
import nciae.db.service.SettingsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SettingsServiceImpl implements SettingsService {

    @Autowired
    private SettingsMapper settingsMapper;

    @Override
    public Settings getSettings() {
        // 从数据库获取设置
        return settingsMapper.getSettings();
    }

    @Override
    public boolean updateSettings(Settings settings) {
        // 更新设置
        int result = settingsMapper.updateSettings(
                settings.getStuMaxNum(),
                settings.getAttendanceRate(),
                settings.getHomeworkRate(),
                settings.getLogRate()
        );
        return result > 0; // 如果更新成功返回 true
    }



}